/**
 * Created by zhaoyanzhi on 16-10-26.
 */
$(document).ready(
    jumpHomePage(),
    jumpPayPage(),
    selectCount()
)
function jumpHomePage(){
    $(".cancel").click(function(){
        location.assign("../html/home.html");
    })
}
function jumpPayPage(){
    $(".weChatPayment").click(function(){
        $.showLoading("微信支付进行中...");
    })
}
function selectCount(){  //选择餐具数量
    $(".canju").click(
        function(){
            addSelectCountButton();
            $("#mainDiv").css("position","fixed");
        })
}
function addSelectCountButton(){  //生成109个数量按钮
    var code3="";
    for(var i=0;i<109;i++){
        code3+='<button class="countButton">' + i + '</button>';
    }
    $('body').append(
        '<div class="countDiv">'+code3+'</div>'
    )
    addSelectCountEvent();
}
function addSelectCountEvent(){   //点击选数
    $(".countButton").click(
        function(){
            var count=$(this).html(); //所选择餐具的数量
            $(".canju").html(count);
            $(".countDiv").html("");
            computeCanJuSumPrice(count); //计算餐具总价
            $(".canju").css("background","limegreen");
        }
    )
}
function computeCanJuSumPrice(count){
    var sumPrice=5*count;
    $("#sumPrice").html(sumPrice+"元")
}